<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    如果 await的 promise 失败了，就会抛出异常，需要通过try catch 捕获错误
    <script>
        async function main() {
            let p = new Promise((resolve,reject) => {
                resolve('OK')
            })

            // 1、 右侧是promise的情况
            let res = await p;
            // 2、 非 promise的情况
            let res2 = await 20;
            // 3、 promise失败的情况
            let p2 = new Promise((resolve,reject) => {
                reject('err')
            })
            try {
                let res3 = await p2;
            }catch (e) {
                console.log(e)
            }
        }

        main()
    </script>
</body>
</html>